{
 "cells": [
  {
   "cell_type": "code",
   "execution_count": 1,
   "id": "initial_id",
   "metadata": {
    "collapsed": true,
    "ExecuteTime": {
     "end_time": "2024-03-30T07:24:24.825912200Z",
     "start_time": "2024-03-30T07:24:23.094931900Z"
    }
   },
   "outputs": [],
   "source": [
    "import pandas as pd\n",
    "import matplotlib.pyplot as plt\n",
    "import numpy as np\n",
    "import warnings\n",
    "\n",
    "from matplotlib.ticker import PercentFormatter\n",
    "\n",
    "warnings.filterwarnings(\"ignore\")\n",
    "%matplotlib inline\n",
    "\n",
    "plt.rcParams['font.sans-serif'] = ['SimHei']\n",
    "plt.rcParams['axes.unicode_minus'] = False"
   ]
  },
  {
   "cell_type": "code",
   "outputs": [
    {
     "data": {
      "text/plain": "      user_ID  user_level  user_month  plus  gender  age  marital_status  \\\n0  000089d6a6           1           7     0       2    3               1   \n1  0000babd1f           1           0     0      -1   -1              -1   \n2  0000bc018b           3          21     0       2    6               2   \n3  0000d0e5ab           3          45     0       1    3               2   \n4  0000dce472           3          67     1      -1   -1              -1   \n\n   education  city_level  purchase_power  \n0          3           4               3  \n1         -1          -1              -1  \n2          3           2               3  \n3          3           2               2  \n4         -1          -1              -1  ",
      "text/html": "<div>\n<style scoped>\n    .dataframe tbody tr th:only-of-type {\n        vertical-align: middle;\n    }\n\n    .dataframe tbody tr th {\n        vertical-align: top;\n    }\n\n    .dataframe thead th {\n        text-align: right;\n    }\n</style>\n<table border=\"1\" class=\"dataframe\">\n  <thead>\n    <tr style=\"text-align: right;\">\n      <th></th>\n      <th>user_ID</th>\n      <th>user_level</th>\n      <th>user_month</th>\n      <th>plus</th>\n      <th>gender</th>\n      <th>age</th>\n      <th>marital_status</th>\n      <th>education</th>\n      <th>city_level</th>\n      <th>purchase_power</th>\n    </tr>\n  </thead>\n  <tbody>\n    <tr>\n      <th>0</th>\n      <td>000089d6a6</td>\n      <td>1</td>\n      <td>7</td>\n      <td>0</td>\n      <td>2</td>\n      <td>3</td>\n      <td>1</td>\n      <td>3</td>\n      <td>4</td>\n      <td>3</td>\n    </tr>\n    <tr>\n      <th>1</th>\n      <td>0000babd1f</td>\n      <td>1</td>\n      <td>0</td>\n      <td>0</td>\n      <td>-1</td>\n      <td>-1</td>\n      <td>-1</td>\n      <td>-1</td>\n      <td>-1</td>\n      <td>-1</td>\n    </tr>\n    <tr>\n      <th>2</th>\n      <td>0000bc018b</td>\n      <td>3</td>\n      <td>21</td>\n      <td>0</td>\n      <td>2</td>\n      <td>6</td>\n      <td>2</td>\n      <td>3</td>\n      <td>2</td>\n      <td>3</td>\n    </tr>\n    <tr>\n      <th>3</th>\n      <td>0000d0e5ab</td>\n      <td>3</td>\n      <td>45</td>\n      <td>0</td>\n      <td>1</td>\n      <td>3</td>\n      <td>2</td>\n      <td>3</td>\n      <td>2</td>\n      <td>2</td>\n    </tr>\n    <tr>\n      <th>4</th>\n      <td>0000dce472</td>\n      <td>3</td>\n      <td>67</td>\n      <td>1</td>\n      <td>-1</td>\n      <td>-1</td>\n      <td>-1</td>\n      <td>-1</td>\n      <td>-1</td>\n      <td>-1</td>\n    </tr>\n  </tbody>\n</table>\n</div>"
     },
     "execution_count": 9,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "user = pd.read_csv('./preprocess_data/JD_user_data.csv')\n",
    "user.head()"
   ],
   "metadata": {
    "collapsed": false,
    "ExecuteTime": {
     "end_time": "2024-03-30T13:38:36.879881600Z",
     "start_time": "2024-03-30T13:38:36.436236500Z"
    }
   },
   "id": "e07279d73b0d768d",
   "execution_count": 9
  },
  {
   "cell_type": "code",
   "outputs": [
    {
     "data": {
      "text/plain": "user_ID           457298\nuser_level             7\nuser_month           169\nplus                   2\ngender                 3\nage                    7\nmarital_status         3\neducation              5\ncity_level             6\npurchase_power         6\ndtype: int64"
     },
     "execution_count": 3,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "user.nunique()"
   ],
   "metadata": {
    "collapsed": false,
    "ExecuteTime": {
     "end_time": "2024-03-29T08:50:06.448322700Z",
     "start_time": "2024-03-29T08:50:06.317579300Z"
    }
   },
   "id": "18e68dd7e91aa1a2",
   "execution_count": 3
  },
  {
   "cell_type": "code",
   "outputs": [
    {
     "data": {
      "text/plain": "457298"
     },
     "execution_count": 7,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "len(user)"
   ],
   "metadata": {
    "collapsed": false,
    "ExecuteTime": {
     "end_time": "2024-03-29T08:58:03.636299700Z",
     "start_time": "2024-03-29T08:58:03.589542Z"
    }
   },
   "id": "39375b72cfe91d23",
   "execution_count": 7
  },
  {
   "cell_type": "code",
   "outputs": [
    {
     "data": {
      "text/plain": "       sku_ID     user_ID         request_time channel\n0  a234e08c57  4c3d6d10c2  2018-03-01 23:57:53  wechat\n1  09b70fcd83  2791ec4485  2018-03-01 22:10:51  wechat\n2  09b70fcd83  eb0718c1c9  2018-03-01 16:34:08  wechat\n3  09b70fcd83  59f84cf342  2018-03-01 22:20:35  wechat\n4  09b70fcd83  59f84cf342  2018-03-01 22:20:01  wechat",
      "text/html": "<div>\n<style scoped>\n    .dataframe tbody tr th:only-of-type {\n        vertical-align: middle;\n    }\n\n    .dataframe tbody tr th {\n        vertical-align: top;\n    }\n\n    .dataframe thead th {\n        text-align: right;\n    }\n</style>\n<table border=\"1\" class=\"dataframe\">\n  <thead>\n    <tr style=\"text-align: right;\">\n      <th></th>\n      <th>sku_ID</th>\n      <th>user_ID</th>\n      <th>request_time</th>\n      <th>channel</th>\n    </tr>\n  </thead>\n  <tbody>\n    <tr>\n      <th>0</th>\n      <td>a234e08c57</td>\n      <td>4c3d6d10c2</td>\n      <td>2018-03-01 23:57:53</td>\n      <td>wechat</td>\n    </tr>\n    <tr>\n      <th>1</th>\n      <td>09b70fcd83</td>\n      <td>2791ec4485</td>\n      <td>2018-03-01 22:10:51</td>\n      <td>wechat</td>\n    </tr>\n    <tr>\n      <th>2</th>\n      <td>09b70fcd83</td>\n      <td>eb0718c1c9</td>\n      <td>2018-03-01 16:34:08</td>\n      <td>wechat</td>\n    </tr>\n    <tr>\n      <th>3</th>\n      <td>09b70fcd83</td>\n      <td>59f84cf342</td>\n      <td>2018-03-01 22:20:35</td>\n      <td>wechat</td>\n    </tr>\n    <tr>\n      <th>4</th>\n      <td>09b70fcd83</td>\n      <td>59f84cf342</td>\n      <td>2018-03-01 22:20:01</td>\n      <td>wechat</td>\n    </tr>\n  </tbody>\n</table>\n</div>"
     },
     "execution_count": 10,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "click = pd.read_csv('./preprocess_data/JD_click_data.csv')\n",
    "click.head()"
   ],
   "metadata": {
    "collapsed": false,
    "ExecuteTime": {
     "end_time": "2024-03-30T13:39:07.772652100Z",
     "start_time": "2024-03-30T13:38:43.670723800Z"
    }
   },
   "id": "f64e471a7738841f",
   "execution_count": 10
  },
  {
   "cell_type": "code",
   "outputs": [
    {
     "data": {
      "text/plain": "sku_ID            27330\nuser_ID         2557836\nrequest_time    2376076\nchannel               5\ndtype: int64"
     },
     "execution_count": 5,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "click.nunique()"
   ],
   "metadata": {
    "collapsed": false,
    "ExecuteTime": {
     "end_time": "2024-03-29T08:51:35.453782600Z",
     "start_time": "2024-03-29T08:51:24.039516Z"
    }
   },
   "id": "345f325c27ce39c0",
   "execution_count": 5
  },
  {
   "cell_type": "code",
   "outputs": [
    {
     "data": {
      "text/plain": "17906095"
     },
     "execution_count": 6,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "len(click)"
   ],
   "metadata": {
    "collapsed": false,
    "ExecuteTime": {
     "end_time": "2024-03-29T08:57:40.253082200Z",
     "start_time": "2024-03-29T08:57:40.197754Z"
    }
   },
   "id": "8f11fb4ffbfad2dc",
   "execution_count": 6
  },
  {
   "cell_type": "code",
   "outputs": [
    {
     "data": {
      "text/plain": "      user_ID  user_level  user_month  plus  gender  age  marital_status  \\\n0  000089d6a6           1           7     0       2    3               1   \n1  000089d6a6           1           7     0       2    3               1   \n2  000089d6a6           1           7     0       2    3               1   \n3  000089d6a6           1           7     0       2    3               1   \n4  000089d6a6           1           7     0       2    3               1   \n\n   education  city_level  purchase_power      sku_ID         request_time  \\\n0          3           4               3  068f4481b3  2018-03-14 14:42:37   \n1          3           4               3  9ac31152dd  2018-03-14 14:37:08   \n2          3           4               3  e99eb7d131  2018-03-14 14:50:24   \n3          3           4               3  e99eb7d131  2018-03-14 14:43:14   \n4          3           4               3  e99eb7d131  2018-03-14 14:40:48   \n\n  channel  \n0     app  \n1     app  \n2     app  \n3     app  \n4     app  ",
      "text/html": "<div>\n<style scoped>\n    .dataframe tbody tr th:only-of-type {\n        vertical-align: middle;\n    }\n\n    .dataframe tbody tr th {\n        vertical-align: top;\n    }\n\n    .dataframe thead th {\n        text-align: right;\n    }\n</style>\n<table border=\"1\" class=\"dataframe\">\n  <thead>\n    <tr style=\"text-align: right;\">\n      <th></th>\n      <th>user_ID</th>\n      <th>user_level</th>\n      <th>user_month</th>\n      <th>plus</th>\n      <th>gender</th>\n      <th>age</th>\n      <th>marital_status</th>\n      <th>education</th>\n      <th>city_level</th>\n      <th>purchase_power</th>\n      <th>sku_ID</th>\n      <th>request_time</th>\n      <th>channel</th>\n    </tr>\n  </thead>\n  <tbody>\n    <tr>\n      <th>0</th>\n      <td>000089d6a6</td>\n      <td>1</td>\n      <td>7</td>\n      <td>0</td>\n      <td>2</td>\n      <td>3</td>\n      <td>1</td>\n      <td>3</td>\n      <td>4</td>\n      <td>3</td>\n      <td>068f4481b3</td>\n      <td>2018-03-14 14:42:37</td>\n      <td>app</td>\n    </tr>\n    <tr>\n      <th>1</th>\n      <td>000089d6a6</td>\n      <td>1</td>\n      <td>7</td>\n      <td>0</td>\n      <td>2</td>\n      <td>3</td>\n      <td>1</td>\n      <td>3</td>\n      <td>4</td>\n      <td>3</td>\n      <td>9ac31152dd</td>\n      <td>2018-03-14 14:37:08</td>\n      <td>app</td>\n    </tr>\n    <tr>\n      <th>2</th>\n      <td>000089d6a6</td>\n      <td>1</td>\n      <td>7</td>\n      <td>0</td>\n      <td>2</td>\n      <td>3</td>\n      <td>1</td>\n      <td>3</td>\n      <td>4</td>\n      <td>3</td>\n      <td>e99eb7d131</td>\n      <td>2018-03-14 14:50:24</td>\n      <td>app</td>\n    </tr>\n    <tr>\n      <th>3</th>\n      <td>000089d6a6</td>\n      <td>1</td>\n      <td>7</td>\n      <td>0</td>\n      <td>2</td>\n      <td>3</td>\n      <td>1</td>\n      <td>3</td>\n      <td>4</td>\n      <td>3</td>\n      <td>e99eb7d131</td>\n      <td>2018-03-14 14:43:14</td>\n      <td>app</td>\n    </tr>\n    <tr>\n      <th>4</th>\n      <td>000089d6a6</td>\n      <td>1</td>\n      <td>7</td>\n      <td>0</td>\n      <td>2</td>\n      <td>3</td>\n      <td>1</td>\n      <td>3</td>\n      <td>4</td>\n      <td>3</td>\n      <td>e99eb7d131</td>\n      <td>2018-03-14 14:40:48</td>\n      <td>app</td>\n    </tr>\n  </tbody>\n</table>\n</div>"
     },
     "execution_count": 43,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "user_click_inner = pd.merge(user, click, on=['user_ID'], how='inner')\n",
    "user_click_inner.head()"
   ],
   "metadata": {
    "collapsed": false,
    "ExecuteTime": {
     "end_time": "2024-03-30T14:04:49.987784800Z",
     "start_time": "2024-03-30T14:04:42.553771200Z"
    }
   },
   "id": "4afe508aca052793",
   "execution_count": 43
  },
  {
   "cell_type": "code",
   "outputs": [
    {
     "data": {
      "text/plain": "6187553"
     },
     "execution_count": 12,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "len(user_click_inner)"
   ],
   "metadata": {
    "collapsed": false,
    "ExecuteTime": {
     "end_time": "2024-03-29T09:02:54.996792700Z",
     "start_time": "2024-03-29T09:02:54.957592Z"
    }
   },
   "id": "51e7d018f4868086",
   "execution_count": 12
  },
  {
   "cell_type": "code",
   "outputs": [],
   "source": [
    "user_click_inner.to_csv('./preprocess_data/user_click_inner.csv', index=False)"
   ],
   "metadata": {
    "collapsed": false,
    "ExecuteTime": {
     "end_time": "2024-03-29T09:04:07.105694300Z",
     "start_time": "2024-03-29T09:03:45.509019900Z"
    }
   },
   "id": "849a0b0da0de4cc1",
   "execution_count": 13
  },
  {
   "cell_type": "code",
   "outputs": [
    {
     "data": {
      "text/plain": "     order_ID     user_ID      sku_ID             order_time  quantity  type  \\\n0  d0cf5cc6db  0abe9ef2ce  581d5b54c1  2018-03-01 17:14:25.0         1     2   \n1  7444318d01  33a9e56257  067b673f2b  2018-03-01 11:10:40.0         1     1   \n2  f973b01694  4ea3cf408f  623d0a582a  2018-03-01 09:13:26.0         1     1   \n3  8c1cec8d4b  b87cb736cb  fc5289b139  2018-03-01 21:29:50.0         1     1   \n4  d43a33c38a  4829223b6f  623d0a582a  2018-03-01 19:13:37.0         1     1   \n\n  promise  original_unit_price  final_unit_price  direct_discount_per_unit  \\\n0       -                 89.0              79.0                       0.0   \n1       2                 99.9              53.9                       5.0   \n2       2                 78.0              58.5                      19.5   \n3       2                 61.0              35.0                       0.0   \n4       1                 78.0              53.0                      19.0   \n\n   quantity_discount_per_unit  bundle_discount_per_unit  \\\n0                        10.0                       0.0   \n1                        41.0                       0.0   \n2                         0.0                       0.0   \n3                        26.0                       0.0   \n4                         0.0                       0.0   \n\n   coupon_discount_per_unit  gift_item  dc_ori  dc_des  \n0                       0.0          0       4      28  \n1                       0.0          0      28      28  \n2                       0.0          0      28      28  \n3                       0.0          0       4      28  \n4                       6.0          0       3      16  ",
      "text/html": "<div>\n<style scoped>\n    .dataframe tbody tr th:only-of-type {\n        vertical-align: middle;\n    }\n\n    .dataframe tbody tr th {\n        vertical-align: top;\n    }\n\n    .dataframe thead th {\n        text-align: right;\n    }\n</style>\n<table border=\"1\" class=\"dataframe\">\n  <thead>\n    <tr style=\"text-align: right;\">\n      <th></th>\n      <th>order_ID</th>\n      <th>user_ID</th>\n      <th>sku_ID</th>\n      <th>order_time</th>\n      <th>quantity</th>\n      <th>type</th>\n      <th>promise</th>\n      <th>original_unit_price</th>\n      <th>final_unit_price</th>\n      <th>direct_discount_per_unit</th>\n      <th>quantity_discount_per_unit</th>\n      <th>bundle_discount_per_unit</th>\n      <th>coupon_discount_per_unit</th>\n      <th>gift_item</th>\n      <th>dc_ori</th>\n      <th>dc_des</th>\n    </tr>\n  </thead>\n  <tbody>\n    <tr>\n      <th>0</th>\n      <td>d0cf5cc6db</td>\n      <td>0abe9ef2ce</td>\n      <td>581d5b54c1</td>\n      <td>2018-03-01 17:14:25.0</td>\n      <td>1</td>\n      <td>2</td>\n      <td>-</td>\n      <td>89.0</td>\n      <td>79.0</td>\n      <td>0.0</td>\n      <td>10.0</td>\n      <td>0.0</td>\n      <td>0.0</td>\n      <td>0</td>\n      <td>4</td>\n      <td>28</td>\n    </tr>\n    <tr>\n      <th>1</th>\n      <td>7444318d01</td>\n      <td>33a9e56257</td>\n      <td>067b673f2b</td>\n      <td>2018-03-01 11:10:40.0</td>\n      <td>1</td>\n      <td>1</td>\n      <td>2</td>\n      <td>99.9</td>\n      <td>53.9</td>\n      <td>5.0</td>\n      <td>41.0</td>\n      <td>0.0</td>\n      <td>0.0</td>\n      <td>0</td>\n      <td>28</td>\n      <td>28</td>\n    </tr>\n    <tr>\n      <th>2</th>\n      <td>f973b01694</td>\n      <td>4ea3cf408f</td>\n      <td>623d0a582a</td>\n      <td>2018-03-01 09:13:26.0</td>\n      <td>1</td>\n      <td>1</td>\n      <td>2</td>\n      <td>78.0</td>\n      <td>58.5</td>\n      <td>19.5</td>\n      <td>0.0</td>\n      <td>0.0</td>\n      <td>0.0</td>\n      <td>0</td>\n      <td>28</td>\n      <td>28</td>\n    </tr>\n    <tr>\n      <th>3</th>\n      <td>8c1cec8d4b</td>\n      <td>b87cb736cb</td>\n      <td>fc5289b139</td>\n      <td>2018-03-01 21:29:50.0</td>\n      <td>1</td>\n      <td>1</td>\n      <td>2</td>\n      <td>61.0</td>\n      <td>35.0</td>\n      <td>0.0</td>\n      <td>26.0</td>\n      <td>0.0</td>\n      <td>0.0</td>\n      <td>0</td>\n      <td>4</td>\n      <td>28</td>\n    </tr>\n    <tr>\n      <th>4</th>\n      <td>d43a33c38a</td>\n      <td>4829223b6f</td>\n      <td>623d0a582a</td>\n      <td>2018-03-01 19:13:37.0</td>\n      <td>1</td>\n      <td>1</td>\n      <td>1</td>\n      <td>78.0</td>\n      <td>53.0</td>\n      <td>19.0</td>\n      <td>0.0</td>\n      <td>0.0</td>\n      <td>6.0</td>\n      <td>0</td>\n      <td>3</td>\n      <td>16</td>\n    </tr>\n  </tbody>\n</table>\n</div>"
     },
     "execution_count": 44,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "order = pd.read_csv('./preprocess_data/JD_order_data.csv')\n",
    "order.head()"
   ],
   "metadata": {
    "collapsed": false,
    "ExecuteTime": {
     "end_time": "2024-03-30T14:04:54.912627400Z",
     "start_time": "2024-03-30T14:04:53.643566300Z"
    }
   },
   "id": "808080e400fc146a",
   "execution_count": 44
  },
  {
   "cell_type": "code",
   "outputs": [
    {
     "data": {
      "text/plain": "549989"
     },
     "execution_count": 15,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "len(order)"
   ],
   "metadata": {
    "collapsed": false,
    "ExecuteTime": {
     "end_time": "2024-03-29T09:11:37.741297600Z",
     "start_time": "2024-03-29T09:11:37.695204800Z"
    }
   },
   "id": "1c28899665b633f3",
   "execution_count": 15
  },
  {
   "cell_type": "code",
   "outputs": [
    {
     "data": {
      "text/plain": "      user_ID  user_level  user_month  plus  gender  age  marital_status  \\\n0  000089d6a6           1           7     0       2    3               1   \n1  000089d6a6           1           7     0       2    3               1   \n2  000089d6a6           1           7     0       2    3               1   \n3  000089d6a6           1           7     0       2    3               1   \n4  000089d6a6           1           7     0       2    3               1   \n\n   education  city_level  purchase_power  ... promise original_unit_price  \\\n0          3           4               3  ...     NaN                 NaN   \n1          3           4               3  ...     NaN                 NaN   \n2          3           4               3  ...       -               330.0   \n3          3           4               3  ...       -               330.0   \n4          3           4               3  ...       -               330.0   \n\n  final_unit_price direct_discount_per_unit quantity_discount_per_unit  \\\n0              NaN                      NaN                        NaN   \n1              NaN                      NaN                        NaN   \n2            215.0                    115.0                        0.0   \n3            215.0                    115.0                        0.0   \n4            215.0                    115.0                        0.0   \n\n   bundle_discount_per_unit  coupon_discount_per_unit gift_item  dc_ori  \\\n0                       NaN                       NaN       NaN     NaN   \n1                       NaN                       NaN       NaN     NaN   \n2                       0.0                       0.0       0.0     2.0   \n3                       0.0                       0.0       0.0     2.0   \n4                       0.0                       0.0       0.0     2.0   \n\n   dc_des  \n0     NaN  \n1     NaN  \n2    43.0  \n3    43.0  \n4    43.0  \n\n[5 rows x 27 columns]",
      "text/html": "<div>\n<style scoped>\n    .dataframe tbody tr th:only-of-type {\n        vertical-align: middle;\n    }\n\n    .dataframe tbody tr th {\n        vertical-align: top;\n    }\n\n    .dataframe thead th {\n        text-align: right;\n    }\n</style>\n<table border=\"1\" class=\"dataframe\">\n  <thead>\n    <tr style=\"text-align: right;\">\n      <th></th>\n      <th>user_ID</th>\n      <th>user_level</th>\n      <th>user_month</th>\n      <th>plus</th>\n      <th>gender</th>\n      <th>age</th>\n      <th>marital_status</th>\n      <th>education</th>\n      <th>city_level</th>\n      <th>purchase_power</th>\n      <th>...</th>\n      <th>promise</th>\n      <th>original_unit_price</th>\n      <th>final_unit_price</th>\n      <th>direct_discount_per_unit</th>\n      <th>quantity_discount_per_unit</th>\n      <th>bundle_discount_per_unit</th>\n      <th>coupon_discount_per_unit</th>\n      <th>gift_item</th>\n      <th>dc_ori</th>\n      <th>dc_des</th>\n    </tr>\n  </thead>\n  <tbody>\n    <tr>\n      <th>0</th>\n      <td>000089d6a6</td>\n      <td>1</td>\n      <td>7</td>\n      <td>0</td>\n      <td>2</td>\n      <td>3</td>\n      <td>1</td>\n      <td>3</td>\n      <td>4</td>\n      <td>3</td>\n      <td>...</td>\n      <td>NaN</td>\n      <td>NaN</td>\n      <td>NaN</td>\n      <td>NaN</td>\n      <td>NaN</td>\n      <td>NaN</td>\n      <td>NaN</td>\n      <td>NaN</td>\n      <td>NaN</td>\n      <td>NaN</td>\n    </tr>\n    <tr>\n      <th>1</th>\n      <td>000089d6a6</td>\n      <td>1</td>\n      <td>7</td>\n      <td>0</td>\n      <td>2</td>\n      <td>3</td>\n      <td>1</td>\n      <td>3</td>\n      <td>4</td>\n      <td>3</td>\n      <td>...</td>\n      <td>NaN</td>\n      <td>NaN</td>\n      <td>NaN</td>\n      <td>NaN</td>\n      <td>NaN</td>\n      <td>NaN</td>\n      <td>NaN</td>\n      <td>NaN</td>\n      <td>NaN</td>\n      <td>NaN</td>\n    </tr>\n    <tr>\n      <th>2</th>\n      <td>000089d6a6</td>\n      <td>1</td>\n      <td>7</td>\n      <td>0</td>\n      <td>2</td>\n      <td>3</td>\n      <td>1</td>\n      <td>3</td>\n      <td>4</td>\n      <td>3</td>\n      <td>...</td>\n      <td>-</td>\n      <td>330.0</td>\n      <td>215.0</td>\n      <td>115.0</td>\n      <td>0.0</td>\n      <td>0.0</td>\n      <td>0.0</td>\n      <td>0.0</td>\n      <td>2.0</td>\n      <td>43.0</td>\n    </tr>\n    <tr>\n      <th>3</th>\n      <td>000089d6a6</td>\n      <td>1</td>\n      <td>7</td>\n      <td>0</td>\n      <td>2</td>\n      <td>3</td>\n      <td>1</td>\n      <td>3</td>\n      <td>4</td>\n      <td>3</td>\n      <td>...</td>\n      <td>-</td>\n      <td>330.0</td>\n      <td>215.0</td>\n      <td>115.0</td>\n      <td>0.0</td>\n      <td>0.0</td>\n      <td>0.0</td>\n      <td>0.0</td>\n      <td>2.0</td>\n      <td>43.0</td>\n    </tr>\n    <tr>\n      <th>4</th>\n      <td>000089d6a6</td>\n      <td>1</td>\n      <td>7</td>\n      <td>0</td>\n      <td>2</td>\n      <td>3</td>\n      <td>1</td>\n      <td>3</td>\n      <td>4</td>\n      <td>3</td>\n      <td>...</td>\n      <td>-</td>\n      <td>330.0</td>\n      <td>215.0</td>\n      <td>115.0</td>\n      <td>0.0</td>\n      <td>0.0</td>\n      <td>0.0</td>\n      <td>0.0</td>\n      <td>2.0</td>\n      <td>43.0</td>\n    </tr>\n  </tbody>\n</table>\n<p>5 rows × 27 columns</p>\n</div>"
     },
     "execution_count": 13,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "user_click_order = pd.merge(user_click_inner, order, on=['user_ID', 'sku_ID'], how='left')\n",
    "user_click_order.head()"
   ],
   "metadata": {
    "collapsed": false,
    "ExecuteTime": {
     "end_time": "2024-03-30T13:40:09.595766Z",
     "start_time": "2024-03-30T13:40:05.600576900Z"
    }
   },
   "id": "2a16c6f311b7ad45",
   "execution_count": 13
  },
  {
   "cell_type": "code",
   "outputs": [
    {
     "data": {
      "text/plain": "      user_ID  user_level  user_month  plus  gender  age  marital_status  \\\n0  000089d6a6           1           7     0       2    3               1   \n1  000089d6a6           1           7     0       2    3               1   \n2  000089d6a6           1           7     0       2    3               1   \n3  000089d6a6           1           7     0       2    3               1   \n4  000089d6a6           1           7     0       2    3               1   \n\n   education  city_level  purchase_power  ... promise original_unit_price  \\\n0          3           4               3  ...       -               330.0   \n1          3           4               3  ...       -               330.0   \n2          3           4               3  ...       -               330.0   \n3          3           4               3  ...       -               330.0   \n4          3           4               3  ...       -               330.0   \n\n  final_unit_price direct_discount_per_unit quantity_discount_per_unit  \\\n0            215.0                    115.0                        0.0   \n1            215.0                    115.0                        0.0   \n2            215.0                    115.0                        0.0   \n3            215.0                    115.0                        0.0   \n4            215.0                    115.0                        0.0   \n\n   bundle_discount_per_unit  coupon_discount_per_unit gift_item  dc_ori  \\\n0                       0.0                       0.0         0       2   \n1                       0.0                       0.0         0       2   \n2                       0.0                       0.0         0       2   \n3                       0.0                       0.0         0       2   \n4                       0.0                       0.0         0       2   \n\n   dc_des  \n0      43  \n1      43  \n2      43  \n3      43  \n4      43  \n\n[5 rows x 27 columns]",
      "text/html": "<div>\n<style scoped>\n    .dataframe tbody tr th:only-of-type {\n        vertical-align: middle;\n    }\n\n    .dataframe tbody tr th {\n        vertical-align: top;\n    }\n\n    .dataframe thead th {\n        text-align: right;\n    }\n</style>\n<table border=\"1\" class=\"dataframe\">\n  <thead>\n    <tr style=\"text-align: right;\">\n      <th></th>\n      <th>user_ID</th>\n      <th>user_level</th>\n      <th>user_month</th>\n      <th>plus</th>\n      <th>gender</th>\n      <th>age</th>\n      <th>marital_status</th>\n      <th>education</th>\n      <th>city_level</th>\n      <th>purchase_power</th>\n      <th>...</th>\n      <th>promise</th>\n      <th>original_unit_price</th>\n      <th>final_unit_price</th>\n      <th>direct_discount_per_unit</th>\n      <th>quantity_discount_per_unit</th>\n      <th>bundle_discount_per_unit</th>\n      <th>coupon_discount_per_unit</th>\n      <th>gift_item</th>\n      <th>dc_ori</th>\n      <th>dc_des</th>\n    </tr>\n  </thead>\n  <tbody>\n    <tr>\n      <th>0</th>\n      <td>000089d6a6</td>\n      <td>1</td>\n      <td>7</td>\n      <td>0</td>\n      <td>2</td>\n      <td>3</td>\n      <td>1</td>\n      <td>3</td>\n      <td>4</td>\n      <td>3</td>\n      <td>...</td>\n      <td>-</td>\n      <td>330.0</td>\n      <td>215.0</td>\n      <td>115.0</td>\n      <td>0.0</td>\n      <td>0.0</td>\n      <td>0.0</td>\n      <td>0</td>\n      <td>2</td>\n      <td>43</td>\n    </tr>\n    <tr>\n      <th>1</th>\n      <td>000089d6a6</td>\n      <td>1</td>\n      <td>7</td>\n      <td>0</td>\n      <td>2</td>\n      <td>3</td>\n      <td>1</td>\n      <td>3</td>\n      <td>4</td>\n      <td>3</td>\n      <td>...</td>\n      <td>-</td>\n      <td>330.0</td>\n      <td>215.0</td>\n      <td>115.0</td>\n      <td>0.0</td>\n      <td>0.0</td>\n      <td>0.0</td>\n      <td>0</td>\n      <td>2</td>\n      <td>43</td>\n    </tr>\n    <tr>\n      <th>2</th>\n      <td>000089d6a6</td>\n      <td>1</td>\n      <td>7</td>\n      <td>0</td>\n      <td>2</td>\n      <td>3</td>\n      <td>1</td>\n      <td>3</td>\n      <td>4</td>\n      <td>3</td>\n      <td>...</td>\n      <td>-</td>\n      <td>330.0</td>\n      <td>215.0</td>\n      <td>115.0</td>\n      <td>0.0</td>\n      <td>0.0</td>\n      <td>0.0</td>\n      <td>0</td>\n      <td>2</td>\n      <td>43</td>\n    </tr>\n    <tr>\n      <th>3</th>\n      <td>000089d6a6</td>\n      <td>1</td>\n      <td>7</td>\n      <td>0</td>\n      <td>2</td>\n      <td>3</td>\n      <td>1</td>\n      <td>3</td>\n      <td>4</td>\n      <td>3</td>\n      <td>...</td>\n      <td>-</td>\n      <td>330.0</td>\n      <td>215.0</td>\n      <td>115.0</td>\n      <td>0.0</td>\n      <td>0.0</td>\n      <td>0.0</td>\n      <td>0</td>\n      <td>2</td>\n      <td>43</td>\n    </tr>\n    <tr>\n      <th>4</th>\n      <td>000089d6a6</td>\n      <td>1</td>\n      <td>7</td>\n      <td>0</td>\n      <td>2</td>\n      <td>3</td>\n      <td>1</td>\n      <td>3</td>\n      <td>4</td>\n      <td>3</td>\n      <td>...</td>\n      <td>-</td>\n      <td>330.0</td>\n      <td>215.0</td>\n      <td>115.0</td>\n      <td>0.0</td>\n      <td>0.0</td>\n      <td>0.0</td>\n      <td>0</td>\n      <td>2</td>\n      <td>43</td>\n    </tr>\n  </tbody>\n</table>\n<p>5 rows × 27 columns</p>\n</div>"
     },
     "execution_count": 15,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "user_click_orderi = pd.merge(user_click_inner, order, on=['user_ID', 'sku_ID'], how='inner')\n",
    "user_click_orderi.head()"
   ],
   "metadata": {
    "collapsed": false,
    "ExecuteTime": {
     "end_time": "2024-03-30T13:41:03.631749800Z",
     "start_time": "2024-03-30T13:41:00.878829200Z"
    }
   },
   "id": "1a2ab042d0ec9645",
   "execution_count": 15
  },
  {
   "cell_type": "code",
   "outputs": [
    {
     "data": {
      "text/plain": "6294495"
     },
     "execution_count": 16,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "len(user_click_order)"
   ],
   "metadata": {
    "collapsed": false,
    "ExecuteTime": {
     "end_time": "2024-03-30T13:41:38.118760900Z",
     "start_time": "2024-03-30T13:41:38.070737900Z"
    }
   },
   "id": "5fe4335d478f27fd",
   "execution_count": 16
  },
  {
   "cell_type": "code",
   "outputs": [
    {
     "data": {
      "text/plain": "2635502"
     },
     "execution_count": 17,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "len(user_click_orderi)"
   ],
   "metadata": {
    "collapsed": false,
    "ExecuteTime": {
     "end_time": "2024-03-30T13:41:55.032271900Z",
     "start_time": "2024-03-30T13:41:55.004952600Z"
    }
   },
   "id": "2f2ed27b79702df8",
   "execution_count": 17
  },
  {
   "cell_type": "code",
   "outputs": [],
   "source": [
    "user_click_order.to_csv('./preprocess_data/user_click_order.csv', index=False)"
   ],
   "metadata": {
    "collapsed": false,
    "ExecuteTime": {
     "end_time": "2024-03-30T07:35:49.210988300Z",
     "start_time": "2024-03-30T07:34:39.386895600Z"
    }
   },
   "id": "eaa27674e72dec12",
   "execution_count": 8
  },
  {
   "cell_type": "code",
   "outputs": [],
   "source": [
    "# 计算Spearman相关系数\n"
   ],
   "metadata": {
    "collapsed": false
   },
   "id": "79df9f53b48dd64a"
  },
  {
   "cell_type": "code",
   "outputs": [],
   "source": [
    "# 计算Pearson相关系数\n"
   ],
   "metadata": {
    "collapsed": false
   },
   "id": "b88bc75d391cc572"
  },
  {
   "cell_type": "code",
   "outputs": [
    {
     "data": {
      "text/plain": "           user_ID  user_level  user_month  plus  gender  age  marital_status  \\\n134908  4b0231d611           4          24     1       1    6               2   \n\n        education  city_level  purchase_power  \n134908          4           3               2  ",
      "text/html": "<div>\n<style scoped>\n    .dataframe tbody tr th:only-of-type {\n        vertical-align: middle;\n    }\n\n    .dataframe tbody tr th {\n        vertical-align: top;\n    }\n\n    .dataframe thead th {\n        text-align: right;\n    }\n</style>\n<table border=\"1\" class=\"dataframe\">\n  <thead>\n    <tr style=\"text-align: right;\">\n      <th></th>\n      <th>user_ID</th>\n      <th>user_level</th>\n      <th>user_month</th>\n      <th>plus</th>\n      <th>gender</th>\n      <th>age</th>\n      <th>marital_status</th>\n      <th>education</th>\n      <th>city_level</th>\n      <th>purchase_power</th>\n    </tr>\n  </thead>\n  <tbody>\n    <tr>\n      <th>134908</th>\n      <td>4b0231d611</td>\n      <td>4</td>\n      <td>24</td>\n      <td>1</td>\n      <td>1</td>\n      <td>6</td>\n      <td>2</td>\n      <td>4</td>\n      <td>3</td>\n      <td>2</td>\n    </tr>\n  </tbody>\n</table>\n</div>"
     },
     "execution_count": 46,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "user_ex = user[user['user_ID']=='4b0231d611']\n",
    "user_ex"
   ],
   "metadata": {
    "collapsed": false,
    "ExecuteTime": {
     "end_time": "2024-03-30T14:10:06.849807300Z",
     "start_time": "2024-03-30T14:10:06.781476600Z"
    }
   },
   "id": "2b5a9b4d8ac5f518",
   "execution_count": 46
  },
  {
   "cell_type": "code",
   "outputs": [
    {
     "data": {
      "text/plain": "             sku_ID     user_ID         request_time channel\n332572   d3e31fdd6e  4b0231d611  2018-03-01 10:24:00     app\n2494980  d3e31fdd6e  4b0231d611  2018-03-05 21:29:41     app",
      "text/html": "<div>\n<style scoped>\n    .dataframe tbody tr th:only-of-type {\n        vertical-align: middle;\n    }\n\n    .dataframe tbody tr th {\n        vertical-align: top;\n    }\n\n    .dataframe thead th {\n        text-align: right;\n    }\n</style>\n<table border=\"1\" class=\"dataframe\">\n  <thead>\n    <tr style=\"text-align: right;\">\n      <th></th>\n      <th>sku_ID</th>\n      <th>user_ID</th>\n      <th>request_time</th>\n      <th>channel</th>\n    </tr>\n  </thead>\n  <tbody>\n    <tr>\n      <th>332572</th>\n      <td>d3e31fdd6e</td>\n      <td>4b0231d611</td>\n      <td>2018-03-01 10:24:00</td>\n      <td>app</td>\n    </tr>\n    <tr>\n      <th>2494980</th>\n      <td>d3e31fdd6e</td>\n      <td>4b0231d611</td>\n      <td>2018-03-05 21:29:41</td>\n      <td>app</td>\n    </tr>\n  </tbody>\n</table>\n</div>"
     },
     "execution_count": 57,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "click_ex = click[click['user_ID']=='4b0231d611'][click['sku_ID']=='d3e31fdd6e']\n",
    "click_ex"
   ],
   "metadata": {
    "collapsed": false,
    "ExecuteTime": {
     "end_time": "2024-03-30T14:14:30.434388700Z",
     "start_time": "2024-03-30T14:14:27.924773700Z"
    }
   },
   "id": "2ccd05d61adb6603",
   "execution_count": 57
  },
  {
   "cell_type": "code",
   "outputs": [
    {
     "data": {
      "text/plain": "56"
     },
     "execution_count": 49,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "len(click_ex)"
   ],
   "metadata": {
    "collapsed": false,
    "ExecuteTime": {
     "end_time": "2024-03-30T14:10:37.477727300Z",
     "start_time": "2024-03-30T14:10:37.422544400Z"
    }
   },
   "id": "69e72978e3807a0c",
   "execution_count": 49
  },
  {
   "cell_type": "code",
   "outputs": [
    {
     "data": {
      "text/plain": "      user_ID  user_level  user_month  plus  gender  age  marital_status  \\\n0  4b0231d611           4          24     1       1    6               2   \n1  4b0231d611           4          24     1       1    6               2   \n\n   education  city_level  purchase_power      sku_ID         request_time  \\\n0          4           3               2  d3e31fdd6e  2018-03-01 10:24:00   \n1          4           3               2  d3e31fdd6e  2018-03-05 21:29:41   \n\n  channel  \n0     app  \n1     app  ",
      "text/html": "<div>\n<style scoped>\n    .dataframe tbody tr th:only-of-type {\n        vertical-align: middle;\n    }\n\n    .dataframe tbody tr th {\n        vertical-align: top;\n    }\n\n    .dataframe thead th {\n        text-align: right;\n    }\n</style>\n<table border=\"1\" class=\"dataframe\">\n  <thead>\n    <tr style=\"text-align: right;\">\n      <th></th>\n      <th>user_ID</th>\n      <th>user_level</th>\n      <th>user_month</th>\n      <th>plus</th>\n      <th>gender</th>\n      <th>age</th>\n      <th>marital_status</th>\n      <th>education</th>\n      <th>city_level</th>\n      <th>purchase_power</th>\n      <th>sku_ID</th>\n      <th>request_time</th>\n      <th>channel</th>\n    </tr>\n  </thead>\n  <tbody>\n    <tr>\n      <th>0</th>\n      <td>4b0231d611</td>\n      <td>4</td>\n      <td>24</td>\n      <td>1</td>\n      <td>1</td>\n      <td>6</td>\n      <td>2</td>\n      <td>4</td>\n      <td>3</td>\n      <td>2</td>\n      <td>d3e31fdd6e</td>\n      <td>2018-03-01 10:24:00</td>\n      <td>app</td>\n    </tr>\n    <tr>\n      <th>1</th>\n      <td>4b0231d611</td>\n      <td>4</td>\n      <td>24</td>\n      <td>1</td>\n      <td>1</td>\n      <td>6</td>\n      <td>2</td>\n      <td>4</td>\n      <td>3</td>\n      <td>2</td>\n      <td>d3e31fdd6e</td>\n      <td>2018-03-05 21:29:41</td>\n      <td>app</td>\n    </tr>\n  </tbody>\n</table>\n</div>"
     },
     "execution_count": 55,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "user_click_ex = pd.merge(user_ex, click_ex, on=['user_ID'], how='inner')\n",
    "user_click_ex"
   ],
   "metadata": {
    "collapsed": false,
    "ExecuteTime": {
     "end_time": "2024-03-30T14:13:49.096651600Z",
     "start_time": "2024-03-30T14:13:49.039171300Z"
    }
   },
   "id": "cd0821a49ed959dc",
   "execution_count": 55
  },
  {
   "cell_type": "code",
   "outputs": [
    {
     "data": {
      "text/plain": "user_ID            1\nuser_level         1\nuser_month         1\nplus               1\ngender             1\nage                1\nmarital_status     1\neducation          1\ncity_level         1\npurchase_power     1\nsku_ID            13\nrequest_time      56\nchannel            1\ndtype: int64"
     },
     "execution_count": 52,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "user_click_ex.nunique()"
   ],
   "metadata": {
    "collapsed": false,
    "ExecuteTime": {
     "end_time": "2024-03-30T14:11:23.676707800Z",
     "start_time": "2024-03-30T14:11:23.637097500Z"
    }
   },
   "id": "f307786927cc938d",
   "execution_count": 52
  },
  {
   "cell_type": "code",
   "outputs": [
    {
     "data": {
      "text/plain": "       order_ID     user_ID      sku_ID             order_time  quantity  \\\n140  0e21093c68  4b0231d611  d3e31fdd6e  2018-03-01 10:25:22.0         1   \n141  0e21093c68  4b0231d611  d3e31fdd6e  2018-03-01 10:25:22.0         1   \n\n     type promise  original_unit_price  final_unit_price  \\\n140     1       2                  0.0               0.0   \n141     1       2                  0.0               0.0   \n\n     direct_discount_per_unit  quantity_discount_per_unit  \\\n140                       0.0                         0.0   \n141                       0.0                         0.0   \n\n     bundle_discount_per_unit  coupon_discount_per_unit  gift_item  dc_ori  \\\n140                       0.0                       0.0          1       3   \n141                       0.0                       0.0          1       3   \n\n     dc_des  \n140      33  \n141      33  ",
      "text/html": "<div>\n<style scoped>\n    .dataframe tbody tr th:only-of-type {\n        vertical-align: middle;\n    }\n\n    .dataframe tbody tr th {\n        vertical-align: top;\n    }\n\n    .dataframe thead th {\n        text-align: right;\n    }\n</style>\n<table border=\"1\" class=\"dataframe\">\n  <thead>\n    <tr style=\"text-align: right;\">\n      <th></th>\n      <th>order_ID</th>\n      <th>user_ID</th>\n      <th>sku_ID</th>\n      <th>order_time</th>\n      <th>quantity</th>\n      <th>type</th>\n      <th>promise</th>\n      <th>original_unit_price</th>\n      <th>final_unit_price</th>\n      <th>direct_discount_per_unit</th>\n      <th>quantity_discount_per_unit</th>\n      <th>bundle_discount_per_unit</th>\n      <th>coupon_discount_per_unit</th>\n      <th>gift_item</th>\n      <th>dc_ori</th>\n      <th>dc_des</th>\n    </tr>\n  </thead>\n  <tbody>\n    <tr>\n      <th>140</th>\n      <td>0e21093c68</td>\n      <td>4b0231d611</td>\n      <td>d3e31fdd6e</td>\n      <td>2018-03-01 10:25:22.0</td>\n      <td>1</td>\n      <td>1</td>\n      <td>2</td>\n      <td>0.0</td>\n      <td>0.0</td>\n      <td>0.0</td>\n      <td>0.0</td>\n      <td>0.0</td>\n      <td>0.0</td>\n      <td>1</td>\n      <td>3</td>\n      <td>33</td>\n    </tr>\n    <tr>\n      <th>141</th>\n      <td>0e21093c68</td>\n      <td>4b0231d611</td>\n      <td>d3e31fdd6e</td>\n      <td>2018-03-01 10:25:22.0</td>\n      <td>1</td>\n      <td>1</td>\n      <td>2</td>\n      <td>0.0</td>\n      <td>0.0</td>\n      <td>0.0</td>\n      <td>0.0</td>\n      <td>0.0</td>\n      <td>0.0</td>\n      <td>1</td>\n      <td>3</td>\n      <td>33</td>\n    </tr>\n  </tbody>\n</table>\n</div>"
     },
     "execution_count": 58,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "order_ex = order[order['user_ID']=='4b0231d611'][order['sku_ID']=='d3e31fdd6e']\n",
    "order_ex"
   ],
   "metadata": {
    "collapsed": false,
    "ExecuteTime": {
     "end_time": "2024-03-30T14:14:56.738624300Z",
     "start_time": "2024-03-30T14:14:56.637342600Z"
    }
   },
   "id": "b355a42dc2b2a47e",
   "execution_count": 58
  },
  {
   "cell_type": "code",
   "outputs": [
    {
     "data": {
      "text/plain": "      user_ID  user_level  user_month  plus  gender  age  marital_status  \\\n0  4b0231d611           4          24     1       1    6               2   \n1  4b0231d611           4          24     1       1    6               2   \n2  4b0231d611           4          24     1       1    6               2   \n3  4b0231d611           4          24     1       1    6               2   \n\n   education  city_level  purchase_power  ... promise original_unit_price  \\\n0          4           3               2  ...       2                 0.0   \n1          4           3               2  ...       2                 0.0   \n2          4           3               2  ...       2                 0.0   \n3          4           3               2  ...       2                 0.0   \n\n  final_unit_price direct_discount_per_unit quantity_discount_per_unit  \\\n0              0.0                      0.0                        0.0   \n1              0.0                      0.0                        0.0   \n2              0.0                      0.0                        0.0   \n3              0.0                      0.0                        0.0   \n\n   bundle_discount_per_unit  coupon_discount_per_unit gift_item  dc_ori  \\\n0                       0.0                       0.0         1       3   \n1                       0.0                       0.0         1       3   \n2                       0.0                       0.0         1       3   \n3                       0.0                       0.0         1       3   \n\n   dc_des  \n0      33  \n1      33  \n2      33  \n3      33  \n\n[4 rows x 27 columns]",
      "text/html": "<div>\n<style scoped>\n    .dataframe tbody tr th:only-of-type {\n        vertical-align: middle;\n    }\n\n    .dataframe tbody tr th {\n        vertical-align: top;\n    }\n\n    .dataframe thead th {\n        text-align: right;\n    }\n</style>\n<table border=\"1\" class=\"dataframe\">\n  <thead>\n    <tr style=\"text-align: right;\">\n      <th></th>\n      <th>user_ID</th>\n      <th>user_level</th>\n      <th>user_month</th>\n      <th>plus</th>\n      <th>gender</th>\n      <th>age</th>\n      <th>marital_status</th>\n      <th>education</th>\n      <th>city_level</th>\n      <th>purchase_power</th>\n      <th>...</th>\n      <th>promise</th>\n      <th>original_unit_price</th>\n      <th>final_unit_price</th>\n      <th>direct_discount_per_unit</th>\n      <th>quantity_discount_per_unit</th>\n      <th>bundle_discount_per_unit</th>\n      <th>coupon_discount_per_unit</th>\n      <th>gift_item</th>\n      <th>dc_ori</th>\n      <th>dc_des</th>\n    </tr>\n  </thead>\n  <tbody>\n    <tr>\n      <th>0</th>\n      <td>4b0231d611</td>\n      <td>4</td>\n      <td>24</td>\n      <td>1</td>\n      <td>1</td>\n      <td>6</td>\n      <td>2</td>\n      <td>4</td>\n      <td>3</td>\n      <td>2</td>\n      <td>...</td>\n      <td>2</td>\n      <td>0.0</td>\n      <td>0.0</td>\n      <td>0.0</td>\n      <td>0.0</td>\n      <td>0.0</td>\n      <td>0.0</td>\n      <td>1</td>\n      <td>3</td>\n      <td>33</td>\n    </tr>\n    <tr>\n      <th>1</th>\n      <td>4b0231d611</td>\n      <td>4</td>\n      <td>24</td>\n      <td>1</td>\n      <td>1</td>\n      <td>6</td>\n      <td>2</td>\n      <td>4</td>\n      <td>3</td>\n      <td>2</td>\n      <td>...</td>\n      <td>2</td>\n      <td>0.0</td>\n      <td>0.0</td>\n      <td>0.0</td>\n      <td>0.0</td>\n      <td>0.0</td>\n      <td>0.0</td>\n      <td>1</td>\n      <td>3</td>\n      <td>33</td>\n    </tr>\n    <tr>\n      <th>2</th>\n      <td>4b0231d611</td>\n      <td>4</td>\n      <td>24</td>\n      <td>1</td>\n      <td>1</td>\n      <td>6</td>\n      <td>2</td>\n      <td>4</td>\n      <td>3</td>\n      <td>2</td>\n      <td>...</td>\n      <td>2</td>\n      <td>0.0</td>\n      <td>0.0</td>\n      <td>0.0</td>\n      <td>0.0</td>\n      <td>0.0</td>\n      <td>0.0</td>\n      <td>1</td>\n      <td>3</td>\n      <td>33</td>\n    </tr>\n    <tr>\n      <th>3</th>\n      <td>4b0231d611</td>\n      <td>4</td>\n      <td>24</td>\n      <td>1</td>\n      <td>1</td>\n      <td>6</td>\n      <td>2</td>\n      <td>4</td>\n      <td>3</td>\n      <td>2</td>\n      <td>...</td>\n      <td>2</td>\n      <td>0.0</td>\n      <td>0.0</td>\n      <td>0.0</td>\n      <td>0.0</td>\n      <td>0.0</td>\n      <td>0.0</td>\n      <td>1</td>\n      <td>3</td>\n      <td>33</td>\n    </tr>\n  </tbody>\n</table>\n<p>4 rows × 27 columns</p>\n</div>"
     },
     "execution_count": 59,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "user_click_order_ex_i = pd.merge(user_click_ex, order_ex, on=['user_ID', 'sku_ID'], how='inner')\n",
    "user_click_order_ex_i"
   ],
   "metadata": {
    "collapsed": false,
    "ExecuteTime": {
     "end_time": "2024-03-30T14:15:01.528857400Z",
     "start_time": "2024-03-30T14:15:01.451211400Z"
    }
   },
   "id": "a31ad98cae562080",
   "execution_count": 59
  },
  {
   "cell_type": "code",
   "outputs": [
    {
     "data": {
      "text/plain": "      user_ID  user_level  user_month  plus  gender  age  marital_status  \\\n0  4b0231d611           4          24     1       1    6               2   \n1  4b0231d611           4          24     1       1    6               2   \n2  4b0231d611           4          24     1       1    6               2   \n3  4b0231d611           4          24     1       1    6               2   \n\n   education  city_level  purchase_power  ... promise original_unit_price  \\\n0          4           3               2  ...       2                 0.0   \n1          4           3               2  ...       2                 0.0   \n2          4           3               2  ...       2                 0.0   \n3          4           3               2  ...       2                 0.0   \n\n  final_unit_price direct_discount_per_unit quantity_discount_per_unit  \\\n0              0.0                      0.0                        0.0   \n1              0.0                      0.0                        0.0   \n2              0.0                      0.0                        0.0   \n3              0.0                      0.0                        0.0   \n\n   bundle_discount_per_unit  coupon_discount_per_unit gift_item  dc_ori  \\\n0                       0.0                       0.0         1       3   \n1                       0.0                       0.0         1       3   \n2                       0.0                       0.0         1       3   \n3                       0.0                       0.0         1       3   \n\n   dc_des  \n0      33  \n1      33  \n2      33  \n3      33  \n\n[4 rows x 27 columns]",
      "text/html": "<div>\n<style scoped>\n    .dataframe tbody tr th:only-of-type {\n        vertical-align: middle;\n    }\n\n    .dataframe tbody tr th {\n        vertical-align: top;\n    }\n\n    .dataframe thead th {\n        text-align: right;\n    }\n</style>\n<table border=\"1\" class=\"dataframe\">\n  <thead>\n    <tr style=\"text-align: right;\">\n      <th></th>\n      <th>user_ID</th>\n      <th>user_level</th>\n      <th>user_month</th>\n      <th>plus</th>\n      <th>gender</th>\n      <th>age</th>\n      <th>marital_status</th>\n      <th>education</th>\n      <th>city_level</th>\n      <th>purchase_power</th>\n      <th>...</th>\n      <th>promise</th>\n      <th>original_unit_price</th>\n      <th>final_unit_price</th>\n      <th>direct_discount_per_unit</th>\n      <th>quantity_discount_per_unit</th>\n      <th>bundle_discount_per_unit</th>\n      <th>coupon_discount_per_unit</th>\n      <th>gift_item</th>\n      <th>dc_ori</th>\n      <th>dc_des</th>\n    </tr>\n  </thead>\n  <tbody>\n    <tr>\n      <th>0</th>\n      <td>4b0231d611</td>\n      <td>4</td>\n      <td>24</td>\n      <td>1</td>\n      <td>1</td>\n      <td>6</td>\n      <td>2</td>\n      <td>4</td>\n      <td>3</td>\n      <td>2</td>\n      <td>...</td>\n      <td>2</td>\n      <td>0.0</td>\n      <td>0.0</td>\n      <td>0.0</td>\n      <td>0.0</td>\n      <td>0.0</td>\n      <td>0.0</td>\n      <td>1</td>\n      <td>3</td>\n      <td>33</td>\n    </tr>\n    <tr>\n      <th>1</th>\n      <td>4b0231d611</td>\n      <td>4</td>\n      <td>24</td>\n      <td>1</td>\n      <td>1</td>\n      <td>6</td>\n      <td>2</td>\n      <td>4</td>\n      <td>3</td>\n      <td>2</td>\n      <td>...</td>\n      <td>2</td>\n      <td>0.0</td>\n      <td>0.0</td>\n      <td>0.0</td>\n      <td>0.0</td>\n      <td>0.0</td>\n      <td>0.0</td>\n      <td>1</td>\n      <td>3</td>\n      <td>33</td>\n    </tr>\n    <tr>\n      <th>2</th>\n      <td>4b0231d611</td>\n      <td>4</td>\n      <td>24</td>\n      <td>1</td>\n      <td>1</td>\n      <td>6</td>\n      <td>2</td>\n      <td>4</td>\n      <td>3</td>\n      <td>2</td>\n      <td>...</td>\n      <td>2</td>\n      <td>0.0</td>\n      <td>0.0</td>\n      <td>0.0</td>\n      <td>0.0</td>\n      <td>0.0</td>\n      <td>0.0</td>\n      <td>1</td>\n      <td>3</td>\n      <td>33</td>\n    </tr>\n    <tr>\n      <th>3</th>\n      <td>4b0231d611</td>\n      <td>4</td>\n      <td>24</td>\n      <td>1</td>\n      <td>1</td>\n      <td>6</td>\n      <td>2</td>\n      <td>4</td>\n      <td>3</td>\n      <td>2</td>\n      <td>...</td>\n      <td>2</td>\n      <td>0.0</td>\n      <td>0.0</td>\n      <td>0.0</td>\n      <td>0.0</td>\n      <td>0.0</td>\n      <td>0.0</td>\n      <td>1</td>\n      <td>3</td>\n      <td>33</td>\n    </tr>\n  </tbody>\n</table>\n<p>4 rows × 27 columns</p>\n</div>"
     },
     "execution_count": 60,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "user_click_order_ex_l = pd.merge(user_click_ex, order_ex, on=['user_ID', 'sku_ID'], how='left')\n",
    "user_click_order_ex_l"
   ],
   "metadata": {
    "collapsed": false,
    "ExecuteTime": {
     "end_time": "2024-03-30T14:16:38.465281900Z",
     "start_time": "2024-03-30T14:16:38.448823Z"
    }
   },
   "id": "90698fcb503a09a9",
   "execution_count": 60
  },
  {
   "cell_type": "code",
   "outputs": [],
   "source": [],
   "metadata": {
    "collapsed": false
   },
   "id": "23af7bb749c97aca"
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 2
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython2",
   "version": "2.7.6"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 5
}
